//
//  AiQuestionListTableViewCell.swift
//  AIImage
//
//  Created by deng on 2023/12/10.
//

import UIKit
import Reusable

class AiQuestionListTableViewCell: UITableViewCell,Reusable {

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupViews()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        setupViews()
    }
    
    let quesionL = UILabel.init()
    let answerL = UILabel.init()
    
    private func setupViews() {
     
        selectionStyle = .none
        backgroundColor = .clear
        
        
        let bgView = UIView.init()
        
        let lineV = UIView.init()
        lineV.backgroundColor = .hexString("#878787")
        contentView.addSubview(lineV)
        lineV.snp.makeConstraints { make in
            make.left.equalTo(20*DS.s)
            make.top.equalToSuperview()
            make.right.equalTo(-20*DS.s)
            make.height.equalTo(1.5*DS.s)
        }
        
        quesionL.numberOfLines = 0
        quesionL.textColor = .white
        quesionL.font = .systemFont(ofSize: 18, weight: .bold)
        bgView.addSubview(quesionL)
        quesionL.snp.makeConstraints { make in
            make.left.equalTo(20*DS.s)
            make.top.equalToSuperview()
            make.right.equalTo(-20*DS.s)
        }
        
        answerL.numberOfLines = 0
        answerL.textColor = .white
        answerL.font = .systemFont(ofSize: 16, weight: .bold)
        bgView.addSubview(answerL)
        answerL.snp.makeConstraints { make in
            make.left.right.equalTo(quesionL)
            make.top.equalTo(quesionL.snp.bottom).offset(16*DS.s)
        }
        
        contentView.addSubview(bgView)
        bgView.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.top.equalTo(20*DS.s)
            make.bottom.equalTo(answerL.snp.bottom).offset(10*DS.s)
            make.bottom.equalToSuperview().offset(-10*DS.s)
        }
    }
    
    func setupData(vo:AIListModel){
        
        quesionL.text = vo.question ?? ""
        answerL.text = vo.answer ?? ""
    }
}
